package com.atguigu.srb.rabbitutil.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: Bright
 * @Date: 2022-05-01 15:53
 * @Description: com.atguigu.srb.rabbitutil.service
 * @version: 1.0
 */
@Service
@Slf4j
public class MQService {

    @Resource
    AmqpTemplate amqpTemplate;

    /**
     * 发送消息
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 消息
     * @return 是否成功
     */
    public boolean sendMessage(String exchange,String routingKey,Object message){
        log.info("发送消息...........");
        amqpTemplate.convertAndSend(exchange,routingKey,message);
        return true;
    }
}
